
package nu.aing.P20140428;

import java.util.Arrays;

/**
 * @author memekmaut@gmail.com
 */
public class SilverbachConjecture {

    public static void main(String[] args) {
        SilverbachConjecture sc = new SilverbachConjecture();

        Long start1 = System.currentTimeMillis();
        System.out.println(Arrays.toString(sc.solve(20)));
        System.out.println(Arrays.toString(sc.solve(30)));
        System.out.println(Arrays.toString(sc.solve(999)));
        System.out.println(Arrays.toString(sc.solve(45)));
        System.out.println(Arrays.toString(sc.solve(2000)));
        Long end1 = System.currentTimeMillis();
        System.out.println("Time:" + (end1 - start1));

        System.out.println("============================");
    }

    public int[] solve(int n) {
        int[] arr = new int[2];
        for (int i = 4; i < n; i++) {
            if (isComposite(i)) {
                for (int j = 4; j < n; j++) {
                    if (isComposite(j)) {
                        if (i + j == n) {
                            arr[0] = i;
                            arr[1] = j;
                            return arr;
                        }
                    }
                }
            }
        }
        return arr;
    }

    private boolean isComposite(int n) {
        for (int i = 2; i <= n / 2; i++) {
            if (n % i == 0) {
                return true;
            }
        }
        return false;
    }
}
